package com.finalhomework.dms.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfigurer implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry){
        registry.addViewController("/").setViewName("stuIndex");
        registry.addViewController("/index.html").setViewName("index");
        registry.addViewController("/stuIndex.html").setViewName("stuIndex");

        /*registry.addViewController("/main.html").setViewName("/bulletin/bulletin");
        registry.addViewController("/announce.html").setViewName("bulletin/announce");*/
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LHInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/user/stuLogin","/index.html","/","/user/login","/css/**","/stuIndex.html","/user/stuLogin","/img/**","/js/**");
    }
}
